package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MallWechatMenuConfig;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by DK on 16/11/16.
 */
@Repository
public interface MallWechatMenuConfigRepository extends JpaRepository<MallWechatMenuConfig, Long>, JpaSpecificationExecutor, MallWechatMenuConfigRepositoryCustom {

    Long countByMallIdAndIsDeleteAndParentIdIsNull(Long mallId, Whether no);

    List<MallWechatMenuConfig> findByParentIdAndMallIdAndIsDeleteOrderBySeqNoDesc(Long parentId, Long mallId, Whether no);

    Long countByMallIdAndParentIdAndIsDelete(Long mallId, Long parentId, Whether no);

    Long findTop1ByMallIdAndIsDeleteAndParentIdIsNullOrderByIdDesc(Long mallId, Whether no);

    Long findTop1ByMallIdAndParentIdAndIsDeleteOrderByIdDesc(Long mallId, Long parentId, Whether no);

    MallWechatMenuConfig findByIdAndMallIdAndIsDelete(Long parentId, Long mallId, Whether no);

    List<MallWechatMenuConfig> findByMallIdAndParentIdIsNullOrderBySeqNoDesc(Long id);

    List<MallWechatMenuConfig> findByMallIdAndIsDeleteAndMenuKeyAndParentIdIsNull(Long mallId, Whether no, String click);

    List<MallWechatMenuConfig> findByMallId(Long mallId);

    List<MallWechatMenuConfig> findByMallIdAndParentId(Long mallId, Long parentId);

    List<MallWechatMenuConfig> findByMallIdAndIsDelete(Long mallId, Whether no);
}
